home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan / Opus 5 - Magellan.iso / DOpus_Install / ARexx / ARexx / AFSUnDelete.dopus5 < prev    next >
Text File  |  1996-07-19  |  4KB  |  151 lines

  1. /*
  2.   $VER: AFSUnDelete.dopus5 1.0 (8.5.96)
  3.   Written by Edmund Vermeulen (edmundv@grafix.xs4all.nl).
  4.  
  5.   ARexx script for Directory Opus 5.5 to simplify the undelete function on
  6.   AFS (Ami-FileSafe) partitions. You can use the copy button to undelete
  7.   files, and renaming and deprotection will be taken care of for you.
  8.  
  9.   Function : ARexx      DOpus5:ARexx/AFSUnDelete.dopus5 {Qp}
  10. */
  11.  
  12. parse arg portname .
  13.  
  14. if portname='' then
  15.    portname='DOPUS.1'
  16. address value portname
  17.  
  18. options results
  19. options failat 21
  20.  
  21. if ~show('l','rexxsupport.library') then
  22.    call addlib('rexxsupport.library',0,-30)
  23.  
  24. lister query source
  25. if rc>0 then do
  26.    dopus request '"No source selected." OK'
  27.    exit
  28.    end
  29. parse var result handle .
  30.  
  31. lister set handle busy on
  32.  
  33. lister query handle path
  34. parse var result device ':'
  35.  
  36. if ~exists(device':.DELDIR') then do
  37.    dopus request '"'device': is not a valid AFS device." OK'
  38.    lister set handle busy off
  39.    exit
  40.    end
  41.  
  42. lister empty handle
  43. lister set handle title 'Reading .deldir...'
  44. lister set handle path device':'
  45. lister refresh handle full
  46.  
  47. filelist=showdir(device':.DELDIR','f',':')
  48.  
  49. do while filelist~=''
  50.    parse var filelist fullname ':' filelist
  51.    parse var fullname filename '@' slotno
  52.    fileinfo=statef(device':.DELDIR/'fullname)
  53.    parse var fileinfo . filesize . protbits days minutes ticks comment
  54.    lister add handle '"'slotno filename'"' filesize '-1' days*86400+minutes*60+ticks/50 protbits comment
  55.    end
  56.  
  57. lister set handle title 'AFS UnDelete'
  58. lister refresh handle full
  59.  
  60. handlername='AFSUnDel'handle
  61. lister set handle handler handlername quotes
  62. call openport(handlername)
  63.  
  64. dopus addtrap 'Copy' handlername
  65.  
  66. lister set handle busy off
  67.  
  68. do until event='inactive'
  69.    if waitpkt(handlername) then do
  70.  
  71.       packet=getpkt(handlername)
  72.       if packet~='00000000'x then do
  73.  
  74.          event=getarg(packet,0)
  75.          handle=getarg(packet,1)
  76.          namestr=getarg(packet,2)
  77.          user=getarg(packet,3)
  78.          pathstr=getarg(packet,4)
  79.          qualifier=getarg(packet,6)
  80.  
  81.          select
  82.             when event='Copy' then
  83.                call docopy
  84.             when event='doubleclick' then do
  85.                parse var namestr slotno ' ' filename
  86.                command doubleclick '"'device':.DELDIR/'filename'@'slotno'"'
  87.                end
  88.             otherwise
  89.                nop
  90.             end
  91.  
  92.          call reply(packet,0)
  93.          end
  94.       end
  95.    end
  96.  
  97. call closeport(handlername)
  98. exit
  99.  
  100.  
  101. docopy:
  102.  
  103.    if user=0 then do
  104.       dopus request '"No destination selected." OK'
  105.       return
  106.       end
  107.  
  108.    lister query user handler
  109.    if ~(result='RESULT' | result='') then do
  110.       dopus request '"Destination is a custom lister!" OK'
  111.       return
  112.       end
  113.  
  114.    lister query user path
  115.    parse var result destdevice ':'
  116.    if destdevice=device then do
  117.       dopus request '"Cannot undelete to the same device!" OK'
  118.       return
  119.       end
  120.    destpath=result
  121.  
  122.    lister set handle busy on
  123.    lister set user busy on
  124.  
  125.    lister set handle newprogress name bar abort
  126.    lister set handle newprogress title 'AFS UnDelete'
  127.  
  128.    lister query handle selentries stem copyfile.
  129.    do i=0 to copyfile.count-1
  130.       parse var copyfile.i slotno ' ' filename
  131.       fullname=filename'@'slotno
  132.  
  133.       lister set handle newprogress name filename
  134.       lister set handle newprogress bar copyfile.count i+1
  135.  
  136.       command wait copyas '"'device':.DELDIR/'fullname'" "'filename'" TO "'destpath'"'
  137.       command wait protect '"'destpath||filename'" SET WD'
  138.       lister select handle '"'copyfile.i'"' off
  139.  
  140.       lister query handle abort
  141.       if result then
  142.          leave
  143.       end
  144.  
  145.    lister clear handle progress
  146.    lister set user busy off
  147.    lister refresh handle full
  148.    lister set handle busy off
  149.    lister read user '"'destpath'"' force
  150.    return
  151.